<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!--page-->
<div class="pages" style="width: 1140px;margin-top: 10px;">
    <ul>
	  <li class="pre">
	  	<c:choose>
  			<c:when test="${casesPageView.currentpage > 1}">
  				<span onclick="goShopCasesTo('${casesPageView.currentpage - 1}')">Previous page</span>
   			</c:when>
   			<c:otherwise>
   				<span>Previous page</span>
   			</c:otherwise>
   		</c:choose>
	  </li>
		<c:forEach begin="${casesPageView.pageindex.startindex}" end="${casesPageView.pageindex.endindex}" var="wp">
			<c:if test="${casesPageView.currentpage==wp}"><li class="page_list curr"><span><a>${wp}</a></span></li></c:if>
			<c:if test="${casesPageView.currentpage!=wp}"><li class="page_list"><span><a href="javascript:goShopCasesTo('${wp}')">${wp}</a></span></li></c:if>
		</c:forEach>
	  <li class="pre">
	  	<c:choose>
  			<c:when test="${casesPageView.currentpage < casesPageView.totalpage}">
  				<span onclick="goShopCasesTo('${casesPageView.currentpage + 1}')">Next page</span>
  			</c:when>
  			<c:otherwise>
  				<span>Next page</span>
  			</c:otherwise>
  		</c:choose>
	  </li>
	  <li style="padding-left: 10px;">${casesPageView.totalpage} Pages , Go&nbsp;</li>
	  <li><input type="number" style="width:50px; height:25px;" id="number" value="${casesPageView.currentpage}" max="${casesPageView.totalpage }" min="1" /></li>
	  <li>&nbsp;Page&nbsp;</li>
	  <li class="pre"><span onclick="goShopCasesTo(document.getElementById('number').value)">Confirm</span></li>
	</ul>
  </div>
  
<script>
	var shopCasesUrl = '';
	$(document).ready(function(){
		$(".page_list").click(function(){
			$(this).addClass("curr").siblings().removeClass("curr");
		});
		
		//分页的请求路径
		shopCasesUrl = '${root }/control/layoutController/ajaxShopCaseList.do?caseShopId=${casesForm.caseShopId}';
	});
	//分页查询
	function goShopCasesTo(number){
		//总页数(最大的页数)
		var totalpage = ${casesPageView.totalpage};
		//当前页
		var currentpage = ${casesPageView.currentpage};
		//跳转页面时,判断跳转的页面是否合理
		if(number != null && number != currentpage && number > 0 && number <= totalpage){
			//var param = $('#searchForm').serialize();
			var param = null;
			shopCasesUrl = shopCasesUrl+'&page='+ number; 
			$.post(shopCasesUrl,param,function(data){
				$('#shopCase').html(data);
			});
		}
	}
</script>
<!--end page-->
